home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
0769A.ZIP
/
ZOOMBOX.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-05-29
|
19KB
|
397 lines
;-----------------------------------------------------------------------------------------------------------------------
; Filename: EXTASM19.ASM
; Program.: Clipper Extended Library 19
; Author..: Gustavo J Grubba.
; Date....: May, 1987
; Notes...: User-defined functions in 8088 assembly for Clipper.
;
; ZoomBox ::= Explode Box for Messages
Name Extasm19
Public ZoomBox
Extrn _ParNI:Far ; Get Integer Parameter
DGROUP GROUP datasg ; Clipper's Data Segment
datasg segment public 'DATA'
Video_Segment dw 0B800h
Video_Page db 0
Video_Mode db ?
Enable_Values db 2Ch,28h,2Dh,29h,2Ah,2Eh,1Eh ; Values to enable CGA display
Window_Row db ?
Window_Column db ?
Window_Width db ?
Window_Height db ?
Win_Row db ?
Win_Column db ?
Win_Width db ?
Win_Height db ?
Win_Attr db ?
Zoom_Time dw ?
Frequency db 0FFh
datasg ends
_Prog Segment
Assume CS:_Prog,DS:DGROUP,ES:DGROUP
;-----------------------------------------------------------------------------------------------------------------------
; ZoomBox
; Syntax: do ZoomBox with <ExpnA>,<ExpnB>,<ExpnC>,<ExpnD>,<ExpnE>
; Return: Nothing
;
; On Entry: ExpnA Upper Left Corner (Row) (0..24)
; ExpnB Upper Left Corner (Column) (0..79)
; ExpnC Width of finished Box (6..80)
; ExpnD Heigth of finished Box (4..24)
; ExpnE Attribute
;
; Attribute is in binary format as expected by 6845
;
; 7 6 5 4 3 2 1 0
;
; B R G B I R G B
;
; Foreground Color
; Intensity
; Background Color
; Blinking
;
; Usage: Example of a .PRG file using ZoomBox
;
; * ZoomTest.PRG
;
; External ZoomBox
; Clear
; Do ZoomBox with 05,04,72,08,79 && Box of 72 by 8 starting at 5,4 using white over red
; Set Color to W+/R && Set text attribute to white over red
; @ 09,32 say "Testing Zoom Box"
; Inkey(30) && Wait a while (or strike any key to go on)
; Set Color to
; Clear
; Quit
;
;
; Compile: C:>Clipper ZoomTest -m <Enter>
; Link...: C:>Plink86 <Enter>
;
; PLINK86plus ( Nantucket ) Version 2.21.
; Copyright (C) 1984, 1985, 1986 by Phoenix Technologies Ltd.,
; All Rights Reserved.
;
; =>fi ZoomTest <Enter>
; =>fi Extasm19 <Enter>
; =>Lib Clipper <Enter>
; =>; <Enter>
;
;------------------- Save Current Registers Values
ZoomBox Proc Far
Push BP ; Save stack
Mov BP,SP
Push DS
Push ES
Push SS
Push DX
;------------------- Check the current video mode to see if it's one of the 80-column text modes (2, 3, or 7).
; If it is, then continue. If it's not, abort this routine.
Mov AH,15 ; Get video page and display mode
Int 10h
Cmp AL,2 ; Video mode 2 ?
Je Par0 ; Yes, then continue
Cmp AL,3 ; Mode 3?
Je Par0 ; Yes, then continue
Mov Video_Segment,0B000h ; Set VIDEO_SEGMENT for monochrome
Cmp AL,7 ; Mode 7 (monochrome)?
Je Par0 ; Yes, then continue
Jmp Exit
;------------------- Get Parameters Sent By Caller
Par0: Mov Video_Mode,AL ; Save Mode
Mov AX,01 ; First parameter
Push AX
Call _PARNI ; Get Upper Left Row
Add SP,2 ; Fix up stack
Mov Window_Row,AL ; Save Value
Cmp AL,20 ; Check for Valid Row
Jb Par1 ; Continue if OK
Jmp Exit ; Leave procedure if not
Par1: Mov AX,02 ; Second param eter
Push AX
Call _PARNI ; Get Upper Left Column
Add SP,2 ; Fix up stack
Mov Window_Column,AL ; Save Value
Cmp AL,72 ; Check for Valid Column
Jb Par2 ; Continue if OK
Jmp Exit ; Leave procedure if not
Par2: Mov AX,03 ; Third parameter
Push AX
Call _PARNI ; Get Window Width
Add SP,2 ; Fix up stack
Mov Window_Width,AL ; Save Value
Cmp AL,07 ; Check for Valid Width
Ja Par3 ; Continue if OK
Jmp Exit ; Leave procedure if not
Par3: Mov AX,04 ; Fourth parameter
Push AX
Call _PARNI ; Get Window Height
Add SP,2 ; Fix up stack
Mov Window_Height,AL ; Save Value
Cmp AL,05 ; Check for Valid Height
Ja Par4 ; Continue if OK
Jmp Exit ; Leave procedure if not
Par4: Mov AX,05 ; Fifth parameter
Push AX
Call _PARNI ; Get Attribute
Add SP,2 ; Fix up stack
Mov Win_Attr,AL ; Save Value
;------------------- Delay Time
Mov Zoom_Time,1000h ; Set zoom delay
;------------------- Set smallest window possible and find out its coordinates
Mov AL,Window_Width ; Get Smallest window UPC
Shr AL,1
Add AL,Window_Column
Sub AL,02
Mov Win_Column,AL
Mov AL,Window_Height ; Get Smallest window UPR
Shr AL,1
Add AL,Window_Row
Dec AL
Mov Win_Row,AL
Mov Win_Width,06 ; Minimum size6x4
Mov Win_Height,04
;------------------- Zoom it out
Init0: Cmp Video_Mode,07 ; Is it monochrome ?
Je Init1 ; Yes, then skip next
Call Video_Disable ; Disable video
Init1: Call Window ; Draw window
Cmp Video_Mode,07 ; Is it monochrome ?
Je Init2 ; Yes, then skip next
Call Video_Enable ; Enable video
Init2: Call Squish ; Squish the speaker
Sub Frequency,04 ; Make frequency lower
Mov AL,Window_Column
Cmp AL,Win_Column ; Has it gotten to its source ?
Je Init3 ; Yes, then don't increment width
Add Win_Width,02 ; No, the incremet its width
Dec Win_Column ; Set new Column
Init3: Mov AL,Win_Row
Cmp AL,Window_Row ; Has it gotten to its source ?
Je Init4 ; Yes, then don't increment height
Add Win_Height,02 ; No, the incremet its height
Dec Win_Row ; Set new Row
Jmp Init0
Init4: Nop
Mov AL,Window_Column
Cmp AL,Win_Column
Jne Init0
Mov AL,Win_Row
Cmp AL,Window_Row ; Has it gotten to its source ?
Jne Init0
;------------------- Restore Registers and Return to Caller
Exit:
Pop DX ; Restore Stack
Pop SS
Pop ES
Pop DS
Pop BP
Ret
ZoomBox Endp
;---------------------------------------------------------------------------------------------------------------------
;------------------- Subroutines
;----------------------------------------------------------------------------------------------------------------------
; VIDEO_OFFSET Calculates the offset address in video memory that corresponds
; to the given row/col, and video page.
;
; Entry: DH,DL - Row, Column | Exit: DI - offset
; BX - Video Page |
;----------------------------------------------------------------------------------------------------------------------
Video_Offset Proc Near
Mov AL,160 ; Row * 160
Mul DH ; Result in AX
Shl DL,1 ; Column * 2
Xor DH,DH ; Byte to wordin DX
Add AX,DX ; Add the two
Mov DI,AX ; Save result in DI
Mov AX,1000h ; Length of one video page
Mul BX ; Page * 1000h
Add DI,AX ; Complete theoffset address
Ret
Video_Offset Endp
;---------------------------------------------------------------------------------------------------------------------
; Video_Enable and Video_Disable routines disable and enable CGA video by wri
; ting to the Mode Select Register
; at port address 3D8h.
;---------------------------------------------------------------------------------------------------------------------
Video_Disable Proc Near
Mov DX,3DAh ; Load Status Register address
Disable1: In AL,DX ; Get video status
Test AL,8 ; Vertical retrace active?
Je Disable1 ; No, then wait until it is
Sub DX,2 ; Load MSR address
Mov AL,25h ; Value to disable video
Out DX,AL ; Send it to the adapter
Ret
Video_Disable Endp
Video_Enable Proc Near
Mov AL,Video_Mode ; Get current video mode
Lea BX,Enable_Values ; Offset of enable value table
Xlat ; Get the value to enable video
Mov DX,3D8h ; Load addressof MSR
Out DX,AL ; OUT the enable value
Ret
Video_Enable Endp
;---------------------------------------------------------------------------------------------------------------
; Squish the speaker
;---------------------------------------------------------------------------------------------------------------
Squish Proc Near
Mov AL,182 ; Notify 8253 that frequency data is coming
Out 67,AL
Mov AL,Frequency ; Low byte frequency
Out 66,AL
Mov AL,00 ; High byte frequency
Out 66,AL
In AL,97 ; Activate Speaker
Or AL,03
Out 97,AL
Mov CX,Zoom_Time ; Time delay for sound duration
Sq1: Loop Sq1
In AL,97 ; Deactivate Speaker
And AL,252
Out 97,AL
Ret
Squish Endp
;-----------------------------------------------------------------------------------------------------------------------
; Window
; ------
;
; Window draws the window border onto the screen. Character/attribute pairs are
; sent directly to video memory for fast
; display speed.
;
;-----------------------------------------------------------------------------------------------------------------------
Window Proc Near
Mov DH,Win_Row ; Get coordinates of window corner
Mov DL,Win_Column
Mov ES,Video_Segment ; Point ES to video buffer
Cld ; Clear DF forstring operations
Mov BL,Video_Page ; Get video page in BX
Xor BH,BH
Call Video_Offset ; Calculate starting address
;------------------- Write the top line of the window border to video.
Mov AL,201 ; Start with upper left corner
Mov AH,Win_Attr ; Set attribute
Stosw
Mov CL,Win_Width ; Do the next n (Columns) characters
Mov CH,00
Mov AL,205
Rep Stosw
Mov AL,187 ; Do upper right corner
Stosw
;------------------- Now write the next n (Rows) lines to the display.
Mov AL,Win_Width ; Set DI for new line
Shl AL,1
Sub AH,AH
Add DI,156
Sub DI,AX
Mov CL,Win_Height ; n (Height) lines to do
Mov CH,00
Window1: Push CX ; Save line counter
Mov AL,186 ; Do leftmost column
Mov AH,Win_Attr
Stosw
Mov AL,32 ; Do next N columns (blank)
Mov AH,Win_Attr
Mov CL,Win_Width
Mov CH,00
Rep Stosw
Mov AL,186 ; Do rightmostcolumn
Mov AH,Win_Attr
Stosw
Mov AL,Win_Width ; Set DI for new line
Shl AL,1
Sub AH,AH
Add DI,156
Sub DI,AX
Pop CX ; Retrieve counter
Loop Window1 ; Loop until finished
;------------------- Finish things up by writing the last line.
Mov AL,200 ; lower left corner
Mov AH,Win_Attr ; Set attribute
Stosw
Mov CL,Win_Width ; next 28 characters
Mov CH,00
Mov AL,205
Rep Stosw
Mov AL,188 ; lower right corner
Stosw
Ret
Window Endp
;------------------- End of Subroutines
_Prog Ends
End
; Eof: EXTASM19.ASM -----------------------------------------------------------
-----------------------------------------